package com.lingxu.module.collection.service.impl;

import com.lingxu.base.common.util.DateUtil;
import com.lingxu.module.collection.entity.*;
import com.lingxu.module.collection.mapper.HomePageMapper;
import com.lingxu.module.collection.service.IHomePageService;
import com.lingxu.module.homeIndex.entity.ParamsDTO;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class HomePageService implements IHomePageService {

    @Resource
    private HomePageMapper homePageMapper;

    @Override
    public List<ModelUseInfo> getModelUseInfo(String region) {
        return homePageMapper.getModelUseInfo(region);
    }

    @Override
    public List<UserCountInfo> getUseCount(ParamsDTO dto) {
        return homePageMapper.getUserCount(dto);
    }

    @Override
    public List<IpCount> getIpCount(String region) {
        return homePageMapper.getIpCount(region);
    }

    @Override
    public List<UserLoginInfo> getUserLoginInfo(ParamsDTO dto) {
        return homePageMapper.getUserLoginInfo(dto);
    }

    @Override
    public List<ModelCount> getModelCount(String region) {
        return homePageMapper.getModelCount(region);
    }

    @Override
    public DataCount getDataCount(String region) {
        DataCount dataCount=new DataCount();
        Integer allcount = homePageMapper.getAllCount(region);
        dataCount.setAllcount(allcount);
        Integer problemcount = homePageMapper.getProblemCount(region);
        dataCount.setProblemcount(problemcount);
        String yearmonth = DateUtil.getDate("yyyy-MM");
        Integer monthUploadcount=homePageMapper.getMonthUploadcount(region,yearmonth);
        dataCount.setMonthUploadcount(monthUploadcount);
        Integer monthUseCount=homePageMapper.getMonthUseCount(region,yearmonth);
        dataCount.setMonthUsecount(monthUseCount);
        return dataCount;
    }

    @Override
    public List<UserCountInfo> getAreaModelCount(String region) {
        return homePageMapper.getAreaModelCount(region);
    }
}
